import server from '@dt/server/dt'
import { userStore } from '@/store/user'

const api = {
  getBindSaMenuById: server.api().get('/sa-admin/api/v1/saWebAuth/authMenu/getBindSysMenuById'),
  saMenuDelete: server.api().post('/sa-admin/api/v1/saWebAuth/del'),
  saMenuSave: server.api().post('/sa-admin/api/v1/saWebAuth/save'),
  saMenuUpdate: server.api().post('/sa-admin/api/v1/saWebAuth/update'),
  saMenuBind: server.api().post('/sa-admin/api/v1/saWebAuth/permissionMenu/bind')
}

function getBindSaMenuById(info) {
  return api.getBindSaMenuById.fetch(info)
}

function saMenuDelete(id) {
  let params = {
    id,
    operatorId: userStore().info.userId
  }

  return api.saMenuDelete.fetch(params)
}

function saMenuSave(info) {
  let params = {
    ...info,
    operatorId: userStore().info.userId
  }

  return api.saMenuSave.fetch(params)
}

function saMenuUpdate(info) {
  let params = {
    ...info,
    operatorId: userStore().info.userId
  }
  return api.saMenuUpdate.fetch(params)
}

function saMenuBind(info) {
  let params = {
    ...info,
    operatorId: userStore().info.userId
  }
  return api.saMenuBind.fetch(params)
}

export default {
  getBindSaMenuById,
  saMenuDelete,
  saMenuSave,
  saMenuUpdate,
  saMenuBind
}
